﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Diagnostics.CodeAnalysis;
using System.IO;

namespace Proggy.Web.Cms.Extensions.Html
{
    /// <summary>
    /// Inline editor
    /// </summary>
    public class ProggyInlineEditor : IDisposable
    {
        public ProggyInlineEditor(TextWriter textWriter)
        {
            if (textWriter == null)
            {
                throw new ArgumentNullException("textWriter");
            }

            // 
            this._textWriter = textWriter;
        }

        private bool _disposed;
        private TextWriter _textWriter;

        [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public void Dispose()
        {
            Dispose(true /* disposing */);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                _disposed = true;
                _textWriter.Write("<div class=\"proggy-inline-editor-footer\">END INLINE EDITOR</div>");
                _textWriter.Write("</div>");
            }
        }
    }
}
